package com.reggie.mvp_demo;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import java.util.Calendar;

import com.reggie.mvp_demo.bean.Event;

import java.util.Calendar;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.TimeZone;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import static java.lang.Long.valueOf;

public class MainActivity extends AppCompatActivity implements MainContract.MainActivityInterface {

    private TextView textView;
    private Button mButton;
    private MainPrestener mPrestener;
    List<Event> events;
    Calendar cal;
    int month;
    int day;


    @Override
    public void setEvent(List <Event> events) {


      textView.setText(events.get(0).getResult().get(0).getDes());
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView = findViewById(R.id.tv_display);
        mButton = findViewById(R.id.btn_loaddata);
        mPrestener = new MainPrestener(this);

        mButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //获取系统时间
                cal = Calendar.getInstance();
                cal.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
                month = cal.get(Calendar.MONTH)+1;
                day = cal.get(Calendar.DAY_OF_MONTH);

                //显示历史上的今天的数据
               mPrestener.getTodayEvent("1.0",month,day);

            }
        });


    }
}



